package com.atm.thirdplt.web.controller.busi;

import com.alibaba.fastjson.JSON;
import com.atm.thirdplt.common.core.domain.AjaxResult;
import com.atm.thirdplt.common.core.domain.his.AtmHisMaterial;
import com.atm.thirdplt.common.core.domain.his.TestWriteHis;
import com.atm.thirdplt.service.AtmHisConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AtmHisConfig)表控制层
 *
 * @author makejava
 * @since 2021-08-26 09:19:07
 */
@Slf4j
@RestController
@RequestMapping("atmHisConfig")
public class AtmHisConfigController {
    /**
     * 服务对象
     */
    @Resource
    private AtmHisConfigService atmHisConfigService;

    /**
     * 通过主键查询单条数据
     *
     * @return 单条数据
     */
    @GetMapping("listHisConfigMap")
    public AjaxResult listHisConfigMap() {
        return AjaxResult.success(atmHisConfigService.listHisConfigMap());
    }

    /**
     * 写入his 中间表
     *
     * @param testWriteHis
     * @return
     */
    @PostMapping("addWriteHis")
    public AjaxResult addWriteHis(@RequestBody  List<TestWriteHis> testWriteHis) {
        log.info("写入his:【{}】", JSON.toJSONString(testWriteHis));
        return atmHisConfigService.addWriteHis(testWriteHis);
    }

    /**
     * 删除his 中间表
     *
     * @param testWriteHis
     * @return
     */
    @PostMapping("delWriteHis")
    public AjaxResult delWriteHis(@RequestBody  List<TestWriteHis> testWriteHis) {
        log.info("删除his:【{}】", JSON.toJSONString(testWriteHis));
        return atmHisConfigService.delWriteHis(testWriteHis);
    }


    /**
     * 写入系统物料库
     *
     * @param
     * @return
     */
    @PostMapping("addHisMaterial")
    public AjaxResult addHisMaterial() {
        return AjaxResult.success(atmHisConfigService.addHisMaterial());
    }

    /**
     * 判断是否此批次是否锁定
     *
     * @param testWriteHis
     * @return
     */
    @PostMapping("booleanLock")
    public AjaxResult booleanLock(@RequestBody TestWriteHis testWriteHis){
        return atmHisConfigService.booleanLock(testWriteHis);
    }
}